/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * altaModLote.java
 *
 * Created on 01-may-2011, 11:20:22
 */

package interfaces.farmacia;

import Definiciones.Definiciones;
import GestorFarmacia.Lote;
import GestorFarmacia.Medicamento;
import clinica.ClinicaView;
import clinica.Interfaces;
import java.io.IOException;
import java.sql.SQLException;
import java.text.ParseException;
import org.jdesktop.application.Action;
import clinica.Interfaz;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import Controlador.*;

/**
 *
 * @author eslogan
 */
public class ModificarLote extends javax.swing.JPanel {
    private ClinicaView app;
    private Interfaces _anterior;
    private Lote _lote;
    private Medicamento _medicamento;

    /** Creates new form altaModLote */
    public ModificarLote(ClinicaView a) {
        app = a;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @Action
    public void cancelar(){
        app.volver(Interfaces.CONSULTAR_LOTE);//Falta conectarla con la de FRUELA (Consultar Lotes)
    }

    @Action
    public void aceptar() throws IOException, ClassNotFoundException, ParseException {
        String exito_lote = null;
        String exito_med = null;

        Pattern cifras = Pattern.compile("[^0-9]+"); // Solo numeros y letras
        Pattern letrasNum = Pattern.compile("[^A-Za-z0-9]+");
        Matcher m = cifras.matcher(unidad_ini2.getText().toString());
        boolean error = false;
        boolean errorFechas = false;
        app.limpiaErrores();

        if (m.find() || unidad_ini2.getText().isEmpty()) {
            error = true;
            Pattern p = Pattern.compile("^-.*"); // Solo numeros!
            m = p.matcher(unidad_ini2.getText().toString());
            if(unidad_ini2.getText().isEmpty())
                app.addError("Debe introducir las unidades iniciales");
            else if(m.find())
                app.addError("Las unidades iniciales no pueden ser negativas");
            else
                app.addError("Las unidades iniciales deben de ser cifras");
        }
        m = cifras.matcher(unidad_res2.getText().toString());
        if(m.find() || unidad_res2.getText().isEmpty()) {
            error = true;
            Pattern p = Pattern.compile("^-.*"); // Solo numeros!
            m = p.matcher(unidad_res2.getText().toString());
            if(unidad_res2.getText().isEmpty())
                app.addError("Debe introducir las unidades restantes");
            else if(m.find())
                app.addError("Las unidades restantes no pueden ser negativas");
            else
                app.addError("Las unidades restantes deben de ser cifras");
        }
        if(fecha_entrada.getDate() == null) {
             error = true;
             errorFechas = true;
             app.addError("Debe introducir una fecha de entrada del lote");
        }
        if(fecha_cad.getDate() == null) {
            error = true;
            errorFechas = true;
            app.addError("Debe introducir una fecha de caducidad del lote");
        }

         if(!errorFechas) {
            if(fecha_cad.getDate().before(fecha_entrada.getDate())) {
                error = true;
                app.addError("La fecha de salida no puede ser anterior a la de entrada");
            }
        }

        if(error){
            app.muestraListaErrores();
        }
        else {
            if(estado2.getSelectedIndex() == 0) {
                exito_lote = Controlador.modificarLote(this._lote.getIdLote(), Definiciones.Estado.DISPONIBLE, fecha_cad.getDate(), fecha_entrada.getDate(),
                                                        Integer.parseInt(unidad_ini2.getText()), Integer.parseInt(unidad_res2.getText()),
                                                        this._medicamento.getIdMedicamento());
            }
            else if(estado2.getSelectedIndex() == 1) {
                 exito_lote = Controlador.modificarLote(this._lote.getIdLote(), Definiciones.Estado.TERMINADO, fecha_cad.getDate(), fecha_entrada.getDate(),
                                                        Integer.parseInt(unidad_ini2.getText()), Integer.parseInt(unidad_res2.getText()),
                                                        this._medicamento.getIdMedicamento());
            }
            else {
                 exito_lote = Controlador.modificarLote(this._lote.getIdLote(), Definiciones.Estado.DESECHADO, fecha_cad.getDate(), fecha_entrada.getDate(),
                                                        Integer.parseInt(unidad_ini2.getText()), Integer.parseInt(unidad_res2.getText()),
                                                        this._medicamento.getIdMedicamento());
            }
            if(exito_lote == null) {
                app.abrirMensajeExito("El lote ha sido modificado correctamente", Interfaces.CONSULTAR_LOTE);
            }
            else {
                app.abrirMensajeError(exito_lote, Interfaces.CONSULTAR_LOTE);
            }
        }
    }

    public void rellenaDatos(Lote lote, Interfaces anterior) throws SQLException, ClassNotFoundException, IOException, ParseException {
        this._anterior = anterior;
        DateFormat fecha_formato = new SimpleDateFormat("dd-MM-yyyy");
        this._lote = lote;
        this._medicamento = lote.getMedicamento();
        String title = lote.getUnidadesInicialesLote()+ " uds, "+this._medicamento.getNombreMedicamento()+", cad: "
                        +fecha_formato.format(lote.getFechaCaducidadLote());
       
        titulo.setText(title);
        code2.setText(lote.getIdLote().toString());
        medicamento2.setText(this._medicamento.getNombreMedicamento());
        unidad_ini2.setText(lote.getUnidadesInicialesLote().toString());
        unidad_res2.setText(lote.getUnidadesRestantesLote().toString());
        fecha_entrada.setDate(lote.getFechaLlegadaLote());
        fecha_cad.setDate(lote.getFechaCaducidadLote());
        if(lote.getEstadoLote().equals(Definiciones.Estado.DISPONIBLE))
            estado2.setSelectedIndex(0);
        else if(lote.getEstadoLote().equals(Definiciones.Estado.TERMINADO))
            estado2.setSelectedIndex(1);
        else
            estado2.setSelectedIndex(2);
        
    }

    public void limpiaEntradas() {
        titulo.setText("");
        code2.setText("");
        medicamento2.setText("");
        unidad_ini2.setText("");
        unidad_res2.setText("");
        estado2.setSelectedIndex(0);
        fecha_entrada.setDate(null);
        fecha_cad.setDate(null);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        titulo = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jPanel21 = new javax.swing.JPanel();
        unidad_ini2 = new javax.swing.JTextField();
        unidad_res2 = new javax.swing.JTextField();
        code2 = new javax.swing.JTextField();
        jLabel49 = new javax.swing.JLabel();
        medicamento2 = new javax.swing.JTextField();
        jLabel50 = new javax.swing.JLabel();
        jLabel51 = new javax.swing.JLabel();
        jLabel52 = new javax.swing.JLabel();
        jLabel53 = new javax.swing.JLabel();
        jLabel54 = new javax.swing.JLabel();
        estado2 = new javax.swing.JComboBox();
        jLabel55 = new javax.swing.JLabel();
        jPanel20 = new javax.swing.JPanel();
        fecha_entrada = new com.toedter.calendar.JDateChooser();
        fecha_cad = new com.toedter.calendar.JDateChooser();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(780, 470));
        setPreferredSize(new java.awt.Dimension(780, 470));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Lote seleccionado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, Interfaz.setFontSize()));
        jPanel1.setFont(Interfaz.setFontSize());
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(780, 470));

        titulo.setBackground(new java.awt.Color(204, 255, 255));
        titulo.setEditable(false);
        titulo.setFont(Interfaz.setFontSize());
        titulo.setName("titulo"); // NOI18N

        jLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 18));
        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/interfaces/resources/Drug-basket-icon32.png"))); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jPanel6.setName("jPanel6"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 76, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(131, 131, 131)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(titulo, javax.swing.GroupLayout.PREFERRED_SIZE, 349, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel2)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(108, 108, 108))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(titulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel7.setName("jPanel7"); // NOI18N

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 24, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 73, Short.MAX_VALUE)
        );

        jPanel8.setName("jPanel8"); // NOI18N

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 66, Short.MAX_VALUE)
        );

        jPanel21.setFont(Interfaz.setFontSize());
        jPanel21.setName("jPanel5"); // NOI18N

        unidad_ini2.setFont(Interfaz.setFontSize());
        unidad_ini2.setName("jTextField10"); // NOI18N

        unidad_res2.setFont(Interfaz.setFontSize());
        unidad_res2.setName("jTextField11"); // NOI18N

        code2.setBackground(new java.awt.Color(204, 255, 255));
        code2.setEditable(false);
        code2.setFont(Interfaz.setFontSize());
        code2.setName("jTextField12"); // NOI18N

        jLabel49.setFont(Interfaz.setFontSize());
        jLabel49.setText("Estado");
        jLabel49.setName("jLabel20"); // NOI18N

        medicamento2.setBackground(new java.awt.Color(204, 255, 255));
        medicamento2.setEditable(false);
        medicamento2.setFont(Interfaz.setFontSize());
        medicamento2.setName("jTextField7"); // NOI18N

        jLabel50.setFont(Interfaz.setFontSize());
        jLabel50.setText("Medicamento");
        jLabel50.setName("jLabel15"); // NOI18N

        jLabel51.setFont(Interfaz.setFontSize());
        jLabel51.setText("Fecha de salida");
        jLabel51.setName("jLabel17"); // NOI18N

        jLabel52.setFont(Interfaz.setFontSize());
        jLabel52.setText("Fecha de entrada");
        jLabel52.setName("jLabel16"); // NOI18N

        jLabel53.setFont(Interfaz.setFontSize());
        jLabel53.setText("Unidades restantes");
        jLabel53.setName("jLabel19"); // NOI18N

        jLabel54.setFont(Interfaz.setFontSize());
        jLabel54.setText("Unidades iniciales");
        jLabel54.setName("jLabel18"); // NOI18N

        estado2.setFont(Interfaz.setFontSize());
        estado2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Disponible", "Terminado", "Desechado" }));
        estado2.setName("jComboBox1"); // NOI18N
        estado2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel55.setFont(Interfaz.setFontSize());
        jLabel55.setText("Código de lote");
        jLabel55.setName("jLabel14"); // NOI18N

        jPanel20.setName("jPanel10"); // NOI18N

        javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
        jPanel20.setLayout(jPanel20Layout);
        jPanel20Layout.setHorizontalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 163, Short.MAX_VALUE)
        );
        jPanel20Layout.setVerticalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        fecha_entrada.setFont(Interfaz.setFontSize());
        fecha_entrada.setName("fecha_entrada"); // NOI18N

        fecha_cad.setFont(Interfaz.setFontSize());
        fecha_cad.setName("fecha_cad"); // NOI18N

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel21Layout.createSequentialGroup()
                        .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(236, 236, 236))
                    .addGroup(jPanel21Layout.createSequentialGroup()
                        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel50)
                            .addComponent(jLabel54)
                            .addComponent(jLabel52)
                            .addComponent(jLabel51)
                            .addComponent(jLabel49)
                            .addComponent(jLabel53)
                            .addComponent(jLabel55))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(code2, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
                            .addComponent(unidad_res2, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
                            .addComponent(fecha_entrada, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
                            .addComponent(fecha_cad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
                            .addComponent(unidad_ini2, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
                            .addComponent(estado2, javax.swing.GroupLayout.Alignment.TRAILING, 0, 561, Short.MAX_VALUE)
                            .addComponent(medicamento2, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE))
                        .addContainerGap())))
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addComponent(jPanel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(code2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel55))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel50)
                    .addComponent(medicamento2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(estado2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel49))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel52)
                    .addComponent(fecha_entrada, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(fecha_cad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel51, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel54)
                    .addComponent(unidad_ini2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel53)
                    .addComponent(unidad_res2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(ModificarLote.class, this);
        jButton2.setAction(actionMap.get("cancelar")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(ModificarLote.class);
        jButton2.setIcon(resourceMap.getIcon("jButton2.icon")); // NOI18N
        jButton2.setLabel(resourceMap.getString("jButton2.label")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jButton1.setAction(actionMap.get("aceptar")); // NOI18N
        jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
        jButton1.setLabel(resourceMap.getString("jButton1.label")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 664, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(43, 43, 43)
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(21, 21, 21))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(563, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addGap(39, 39, 39))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jComboBox1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField code2;
    private javax.swing.JComboBox estado2;
    private com.toedter.calendar.JDateChooser fecha_cad;
    private com.toedter.calendar.JDateChooser fecha_entrada;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel53;
    private javax.swing.JLabel jLabel54;
    private javax.swing.JLabel jLabel55;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JTextField medicamento2;
    private javax.swing.JTextField titulo;
    private javax.swing.JTextField unidad_ini2;
    private javax.swing.JTextField unidad_res2;
    // End of variables declaration//GEN-END:variables

}
